package com.heima.jopo.web;

import com.heima.jopo.obj.UserInfo;
import com.heima.jopo.utilconn.GetConn;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class RegUser {

    //用户注册的方法
    public void  reg(UserInfo userinfo){

        try {
            Connection conn = GetConn.getConn();

            String sql="insert into t_user_info values (?,?,?,?,?,?,?)";

            PreparedStatement ps = conn.prepareStatement(sql);

            ps.setInt(1,0);
            ps.setString(2,userinfo.getPhone());
            ps.setString(3, userinfo.getPasswrod());
            ps.setString(4, userinfo.getUsername());
            ps.setString(5,userinfo.getSex());
            ps.setString(6,userinfo.getBirthday());
            ps.setString(7,userinfo.getCareer());



            int i = ps.executeUpdate();

               if (i>0){
                   System.out.println("插入成功");


               }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }


    }
}
